<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>快招</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="/public/weixin/css/mui.min.css">
		<link rel="stylesheet" href="/public/weixin/css/iconfont/iconfont.css" />
		<link rel="stylesheet" href="/public/weixin/css/css/index.css">
	</head>
<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">加盟我们</h1>
	</header>
	<div class="mui-content">
		<p class="own_shenqing_p">
			请填写个人真实信息，以免影响后期提现业务！
		</p>
		<div class="own_shenqing">
			<div class="own_shenqing_list">
				<div class="own_shenqing_item">姓名</div>
				<div class="own_shenqing_item">
					<input type="text" id="name" name="name" placeholder="请填写真实姓名"/>
				</div>
			</div>
			
			<div class="own_shenqing_list">
				<div class="own_shenqing_item">
					身份证
				</div>
				<div class="own_shenqing_item">
					<input type="text" id="card" name="card" placeholder="请填写个人身份证号码"/>
				</div>
			</div>
			
			<div class="own_shenqing_list" >
					<div class="own_shenqing_item"  style="margin-top: 2%;">
						性别
					</div>
						<?php echo ($sex); ?>
		   </div>
		   
		<div class="own_shenqing_list">
				<div class="own_shenqing_item">手机号</div>
				<div class="own_shenqing_item">
					<input type="tel" id="mobile" name="mobile" placeholder="请填写手机号码"/>
					<input class="yanzhengma" id="getCode" type="button" value="获取验证码"/>
				</div>
			</div>
			<div class="own_shenqing_list">
				<div class="own_shenqing_item">验证码</div>
				<div class="own_shenqing_item">
					<input type="tel" id="mobile_code" name="mobile_code" placeholder="请输入验证码"/>
				</div>
			</div>
			
		</div>
		<div class="own_shenqing_button">
			<div class="mui-content-padded">
				<button type="button" id="joinBtn" class="mui-btn mui-btn-primary mui-btn-block">
					确认
				</button>
			</div>
		</div>
	</div>
</body>
<script src="/public/js/mui/js/mui.js"></script>
<script src="/public/js/jquery.js"></script>
<script type="text/javascript">
$(function() {
	var countdown;
	var countdownNum=60;
	$("#getCode").click(function(){
		var $mobile = $("#mobile").val();
		if($mobile == ''){
			mui.toast("手机号码不能为空！");
			return;
		}
		var reg = /^1[34758]\d{9}$/;
		if (!reg.test($mobile)) {
			mui.toast('请输入正确的手机号码');
			return;
		};
		$("#getCode").attr("disabled",true);
		countdown = countdownNum;
		settime();
		mui.ajax("<?php echo U('User/getCode');?>", {
			data: {mobile_phone: $mobile},
			dataType: 'json', //服务器返回json格式数据
			type: 'POST', //HTTP请求类型
			success: function(data) {
				if (data['state'] != 1) {
					$("#getCode").removeAttr("disabled");
					countdown = 0;
				} else {}
			},
			error: function(xhr, type, errorThrown) {
				$("#getCode").removeAttr("disabled");
			}
		});
	});
	
	$("#joinBtn").click(function(){
		var $name = $("#name").val();
		var $mobile = $("#mobile").val();
		var $card = $("#card").val();
		var $sex = $("input[name='sex']:checked").val();
		var $mobile_code = $("#mobile_code").val();
		if($name == ''){
			mui.toast("真实姓名不能为空！");
			return;
		}
		if($card == ''){
			mui.toast("身份证不能为空！");
			return;
		}
		if($sex == ''){
			mui.toast("性别不能为空！");
			return;
		}
		if($mobile == ''){
			mui.toast("手机号码不能为空！");
			return;
		}
		if($mobile_code == ''){
			mui.toast("手机验证码不能为空！");
			return;
		}
		mui.ajax("<?php echo U('User/join_post');?>",{
			data : {
				"name" : $name,
				"mobile" : $mobile,
				"mobile_code" : $mobile_code,
				"card" : $card,
				"sex" : $sex
			},
			dataType : 'json',//服务器返回json格式数据
			type : 'post',//HTTP请求类型
			timeout : 10000,//超时时间设置为10秒；
			success : function(data){
				//服务器返回响应，根据响应结果，分析是否登录成功；
				if (data['state'] == 1) {
					window.location.href="<?php echo U('User/join');?>";
				}else{
					mui.alert(data['msg']);
				}
			},
			error:function(xhr,type,errorThrown){
				//异常处理；
				console.log(type);
			}
		});
	});
	
	//倒计时处理
	function settime() {
		if (countdown == 0) {
			$("#getCode").removeAttr("disabled");
			$("#getCode").val("验证码");
			countdown = countdownNum;
		} else {
			countdown--;
			$("#getCode").val(countdown+"秒");
			setTimeout(function() {
				settime();
			}, 1000);
		}
	}
});
</script>
</html>